<template>
  <div
    class="wrap-item"
    :style="{
      '--scroll-width': '80px',
    }"
  >
    <div class="wrap-btn-group">
      <span class="wrap-btn wrap-go-back" @click="go">返回</span>
    </div>
    <div class="wrap-other-roll">
      <!-- 基础信息 -->
      <div class="card">
        <div class="title">基础信息</div>
        <item-detail :item="companyBase" />
      </div>
      <!--  评分列表 -->
      <div class="card">
        <div class="title"> 评分列表</div>
        <el-table
          :data="companyScore"
          :header-cell-style="{ background: '#F6F7F9' }"
        >
          <el-table-column prop="companyName" label="企业名称"></el-table-column>
          <el-table-column prop="companyNo" label="统一信用代码"></el-table-column>
          <el-table-column prop="typeTxt" label="入驻身份"></el-table-column>
          <el-table-column prop="score" label="评分"></el-table-column>
          <el-table-column prop="addTime" label="新增时间"></el-table-column>
        </el-table>
      </div>
      <!-- 审批信息 -->
      <div class="card">
        <div class="title">审批信息</div>
        <el-table
          :data="approveItem"
          :header-cell-style="{ background: '#F6F7F9' }"
        >
          <el-table-column prop="title" label="节点名称"> </el-table-column>
          <el-table-column prop="taskUserName" label="处理人">
          </el-table-column>
          <el-table-column label="处理结果">
            <template slot-scope="scope">
              <span v-if="scope.row.status == 0">正在执行中</span>
              <span v-if="scope.row.status == 1">通过</span>
              <span v-if="scope.row.status == 2">驳回</span>
            </template>
          </el-table-column>
          <el-table-column prop="auditNote" label="处理意见">
            <template slot-scope="scope">
              <el-tooltip
                popper-class="ellipsis-tip"
                :content="scope.row.auditNote"
                placement="top-start"
              >
                <span class="ellipsis">{{ scope.row.auditNote }}</span>
              </el-tooltip>
            </template>
          </el-table-column>
          <el-table-column prop="updateTime" label="处理时间">
          </el-table-column>
          <el-table-column label="附件" width="50px" align="center">
            <template slot-scope="scope">
              <el-link
                type="primary"
                :underline="false"
                @click="view(scope.row)"
                >查看</el-link
              >
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <file-preview :visible="isLook" :data="lookData" @close="isLook = false" />
  </div>
</template>

<script>
import itemDetail from './../components/detail.vue'
import filePreview from '@c/filePreview.vue'
export default {
  components: { itemDetail, filePreview },
  data() {
    return {
      companyBase: {},
      approveItem: [],
      companyScore:[],
      lookData: [],
      isLook: false,
    }
  },
  created() {
    if (this.$route.query.id) {
      this.itemList()
    }
  },
  methods: {
    go() {
      //返回
      this.$store.dispatch('tags/delVisitedRoute', {
        path: this.$route.path,
      })
      this.$router.push('/supplierCenter/manage')
    },
    itemList() {
      // 获取列表
      this.$axios
        .get(`/admin/company/find?id=${this.$route.query.id}`)
        .then((data) => {
          this.companyBase = {}
          this.approveItem = []
          this.companyScore = []
          if (data.code == 200) {
            this.companyBase = data.data.companyBase || {}
            this.companyBase.userItemTypeTxt = data.data.userItemTypeTxt
            this.approveItem = data.data.approveItem || []
            this.companyScore = data.data.companyScore || []
          } else {
            this.$message.error(data.msg)
          }
        })
    },
    view(item) {
      //查看
      this.lookData = this.fileArr(item.auditFile)
      this.isLook = true
    },
    fileArr(fileStr) {
      if (Object.prototype.toString.call(fileStr).slice(8, -1) === 'Array') {
        return fileStr
      } else {
        let arrtry = []
        try {
          arrtry = fileStr ? JSON.parse(fileStr) : []
          return arrtry
        } catch (error) {
          arrtry = []
          return arrtry
        }
      }
    },
  },
}
</script>
<style lang="scss" scoped>
.card {
  padding-bottom: 20px;
  .title {
    color: #45ab49;
    border-bottom: 1px solid #45ab49;
    padding: 10px 0;
    margin-bottom: 15px;
  }
}
</style>
